package net.xo68.destiny.starter.common;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import net.xo68.destiny.contract.common.SystemConstants;
import net.xo68.destiny.core.util.IpUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Data
@Slf4j
@Configuration
@ConfigurationProperties("destiny.common")
public class SchedulerCommonProperties {

    private boolean enable=true;

    /**
     * 节点Ip，不设置，自动取
     */
    private String nodeIp;

    /**
     * 心跳周期，单位：秒，默认：45
     */
    private long heartbeatPeriodSecond= SystemConstants.HEARTBEAT_PERIOD_DEFAULT;
    /**
     * 节点资源监控过期时间，单位：秒，默认：5分钟
     */
    private Long nodeMonitorExpired=300L;

    /**
     * 管理端与工作节点互相访问的令牌
     */
    private String apiAccessToken ="admin";

    /**
     * http重试次数
     */
    private int rpcRetryCount=3;



    public String getNodeRealIp(){
        if(StringUtils.isNotBlank(this.nodeIp)){
            return this.nodeIp;
        }
        return IpUtil.getIp();
    }
}
